package concurrent;

public class InterruptTest {

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(){
            @Override
            public void run() {
                while (true) {
                    System.out.println(this.getState());
                    if (Thread.currentThread().isInterrupted()){
                        System.out.println("interrupted");
                        System.out.println(Thread.interrupted());
                        break;
                    }
                    Thread.yield();
                }
            }
        };

        t1.start();
        Thread.sleep(1000L);
        t1.interrupt();
    }
}
